//
//  Data+Extension.swift
//  SwiftProject
//
//  Created by qindong on 2021/7/15.
//

import Foundation

extension Data {
    // MARK: - 将data转化对应Model
    func toModel<T: HandyJSON>(_ type: T.Type) -> T? {
        if let t : T = JSONDeserializer<T>.deserializeFrom(json: String(data: self, encoding: .utf8)!) {
            return t
        }
        return nil
    }
}
